#include "empyrical.h"
#include <chrono>


int main() {
    
    // 测试时间戳功能
    double inputTimestamp = 1609459200.0; // January 1, 2021
    std::chrono::system_clock::time_point utcTime = getUtcTimestamp(inputTimestamp);
    // Print the UTC time
    std::time_t utcTimeAsTm = std::chrono::system_clock::to_time_t(utcTime);
    std::cout << "UTC Time: " << std::asctime(std::gmtime(&utcTimeAsTm)) << std::endl;
    // 测试_adjust_returns功能
    std::vector<double> a = {1.0,2.0,3.0,5.0};
    double b = 0.2;
    std::vector<double> c = _adjust_returns(a,b);
    printVector(c);

    // 测试年化功能
    std::string period = "monthly";
    double customAnnualization = 0;
    // Calculate annualization factor
    float factor = annualization_factor(period, customAnnualization);
    // Print the result
    std::cout << "Annualization Factor: " << factor << std::endl;

    // 测试dataframe简单收益率功能
    std::cout << "test simple_return from axis=0,index=false, means dataframe" << std::endl;
    std::vector<std::vector<double>> prices = {{100.0, 105.0, 110.0}, {110.0, 112.0, 108.0}, {108.0, 107.0, 105.0}};
    std::vector<double> index = {20231025.000000000, 20231026.000000000,20231027.0000000000};
    std::vector<std::string> columns = {"x","y","z"};
    DataFrame prices_df;
    prices_df.dataframe = prices;
    prices_df.index = index;
    prices_df.columns = columns;

    // Calculate simple returns
    DataFrame returns_df;
    returns_df = simpleReturns(prices_df);
    //Print the returns
    printDataFrame(returns_df);
    

    // 计算累计收益率
    std::cout << "cum_return_df" << std::endl;
    DataFrame cum_returns_df = cum_returns(returns_df);
    printDataFrame(cum_returns_df);

    // 计算累计净值
    std::cout << "cum_return_df" << std::endl;
    DataFrame cum_returns_df_1 = cum_returns_final(returns_df);
    printDataFrame(cum_returns_df_1);

    // 获取当前时间的纳秒时间戳
    long long currentNanoTimestamp = getCurrentNanoTimestamp();
    std::cout << "Current Nano Timestamp: " << currentNanoTimestamp << std::endl;

    //将纳秒时间戳转换为字符串时间
    std::string timeString = nanoTimestampToString(currentNanoTimestamp);
    std::cout << "String Time: " << timeString << std::endl;

    // 将字符串时间转换为纳秒时间戳
    long long convertedNanoTimestamp = stringToNanoTimestamp("2023-10-30 15:30:00.1000");
    std::cout << "Converted Nano Timestamp: " << convertedNanoTimestamp << std::endl;



    return 0;
}


